<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/7/11
 * Time: 14:05
 */
namespace app\myself\controller;

use think\Controller;

class Myself extends Controller
{
    //当前城市
//    public function city()
//    {
//          $location = (isset($_GET['location']) && trim($_GET['location'])) ? trim($_GET['location']) : 0;
//          $url = file_get_contents('http://apis.map.qq.com/ws/geocoder/v1/?location='.$location.'&key=VFKBZ-TVW34-ZRDUY-XMJSB-JLIHE-BMFNM');
//        echo $url;
//    }

    //音乐
//    public function music() {
//        $url = file_get_contents('http://music.163.com/php/music.php');
////        echo $url;
//        echo json_encode($url);
//    }


    //天气
    public function tianqi() {
//        $lng = (isset($_GET['lng']) && trim($_GET['lng'])) ? trim($_GET['lng']) : 0;
//        $lat = (isset($_GET['lat']) && trim($_GET['lat'])) ? trim($_GET['lat']) : 0;
//
//        $url = file_get_contents('http://route.showapi.com/9-5?showapi_appid=40224&showapi_sign=8441bd40a9604006ace97939f191f0ee&from=5&lng='.$lng.'&lat='.$lat);
//        echo $url;
            $city = '郑州';
            //定义接口地址
            $encode_url ='http://php.weather.sina.com.cn/xml.php?city='.urlencode(mb_convert_encoding($city,'gb2312','utf8')).'&password=DJOYnieT8234jlsK&day=1';
            //请求接口地址 获取xml
            $xml_source = file_get_contents($encode_url);
            // var_dump($xml_source);

            //利用simplexml解析类 将xml 转成对象
            $xml_object = simplexml_load_string($xml_source);
            // var_dump($xml_object);
            echo $xml_object->Weather->status1;
    }




}



